<?php

if (!function_exists('urlAlias')) {

    function urlAlias($str, $extend = ".html", $baseUrl = "") {
        if (!empty($baseUrl)) {
            return $baseUrl . "/" . $str . $extend;
        } else {
            return base_url() . $str . $extend;
        }
    }

}
if (!function_exists('getPaginationConfig')) {

    function getPaginationConfig($data) {
        $config = array();
        $config['page_query_string'] = FALSE;
        $config['query_string_segment'] = 'page';
        $config['base_url'] = $data['base_url'];
        $config['total_rows'] = $data['num'];
        $config['first_link'] = '<<';
        $config['last_link'] = '>>';
        $config['prev_link'] = '<';
        $config['next_link'] = '>';
        $config['per_page'] = $data['per_page'];
        $config['num_links'] = 2;
        $config['uri_segment'] = $data['uri_segment'];
        return $config;
    }

}

function get_from_group_banner($group_id = 0) {
    $ci = get_instance();
    $ci->db->select('banners.*');
    $ci->db->where('banners.group_id', $group_id);
    $ci->db->where('banners.bl_active', 1);
    $ci->db->order_by('banners_id', 'DESC');
    $query = $ci->db->get('banners');
    return $query->result();
}

if (!function_exists('priceFormat')) {

    function priceFormat($data) {
        return number_format($data, 0, ",", ".");
    }

}

if (!function_exists('get_view_product')) {

    function get_view_product($item) {
        $ci = get_instance();
        if(!empty($item)) {
            return $ci->load->view("product/item_view", array('item'=>$item), true);
        }
        return;
    }

}
if (!function_exists('get_view_product_home')) {

    function get_view_product_home($item) {
        $ci = get_instance();
        if(!empty($item)) {
            return $ci->load->view("product/item_view_home", array('item'=>$item), true);
        }
        return;
    }

}